package com.hertz.alarm.service;

import java.io.Serializable;

import com.hertz.alarm.dao.AbstractEntity;


public interface EntityService {
	/**
	 * local cache 缓存实体对象
	 * afterReturing 调用 entityAOP，若为空从数据库中获取
	 * @param id
	 * @param clazz
	 * @return
	 */
//	@Cacheable(value="entity",condition="#root.target.isCache(#clazz.getSimpleName().toLowerCase())",key="#clazz.getSimpleName().toLowerCase() + '_' + #id")
	public  <T extends AbstractEntity<ID>, ID extends Serializable> T getById(ID id, Class<T> clazz);
	
	public  <T extends AbstractEntity<ID>, ID extends Serializable> T getUnCacheById(ID id, Class<T> clazz);
	
//	@CachePut(value = "entity", condition = "#root.target.isCache(#t.getClass().getSimpleName().toLowerCase())",unless="#result != null", key = "#t.getClass().getSimpleName().toLowerCase() + '_' + #result.getId()")
	public <T extends AbstractEntity<ID>, ID extends Serializable> T save(T t);
	
//	@CacheEvict(value = "entity", condition = "#root.target.isCache(#t.getClass().getSimpleName().toLowerCase())", key = "#root.target.generateKey(#t)")
	public <T extends AbstractEntity<ID>, ID extends Serializable> T update(T t);
	
//	@CacheEvict(value = "entity", condition = "#root.target.isCache(#t.getClass().getSimpleName().toLowerCase())", key = "#t.getClass().getSimpleName().toLowerCase() + '_' + #t.getId()")
	public <T extends AbstractEntity<ID>, ID extends Serializable> ID delete(T t);
	
//	@CacheEvict(value = "entity", condition = "#root.target.isCache(#clazz.getSimpleName().toLowerCase())", key = "#clazz.getSimpleName().toLowerCase() + '_' + #id")
	public <T extends AbstractEntity<ID>, ID extends Serializable> void delete(ID id,Class<T> clazz);
////	@Cacheable(value = "ssoUser", key = "'ssoUser_' + #id")
//	public UserDetail getUserDetailFromSSOById(long id);
//	
//	public UserDetail getBaseUserFromSSOById(long uid);
//	public Map<String, UserDetail> getBaseUsersFromSSO(List<String> uids);
//	
//	public List<UserDetail> getUserDetailFromSSOByIds(Collection ids);
////	@CacheEvict(value = "userDetail", key = "'userDetail_' + #id")
//	public UserDetail getUserDetailFromSSOByName(String name);
//	
//	public UserDetail getUserDetailFromSSOByEmail(String email);
//	public  boolean isCache(String entityName);
//	public <T extends AbstractEntity<ID>, ID extends Serializable> String generateKey(T t);
}
